<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: appHeader"></head>
<body id="history-body" ontouchstart>
<div class="weui-form-preview">
    <div class="weui-form-preview__hd">
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">生产令号</label>
            <b class="weui-form-preview__item" th:text="${tran.prodNo}"></b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">图号</label>
            <b class="weui-form-preview__item" th:text="${tran.drawNo}"></b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">零件名称</label>
            <b class="weui-form-preview__item" th:text="${tran.drawName}"></b>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">零件数量</label>
            <b class="weui-form-preview__item" th:text="${tran.drawNum}"></b>
        </div>
    </div>
    <h2 th:if="${content != null}" style="margin-top: 16px;text-align: center" th:text="${content}"></h2>
<!--    <a onclick="jumpPage()" href="javascript:void(0)">上传</a>-->
<!--    <h2 th:if="${#lists.isEmpty(list)} and ${#lists.isEmpty(completeList)}" style="margin-top: 16px;text-align: center">查无记录</h2>-->
<!--    <h2 th:if="${#lists.isEmpty(list)} and ${completeList.size() > 0}" style="margin-top: 16px;text-align: center">该零件已全部转序</h2>-->
    <div th:if="${content  == null or content  == '' }">
        <div class="weui-form-preview__bd">
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">转序类型</label>
                <a class="weui-form-preview__item" th:if="${tran.type == 1}">制作件</a>
                <a class="weui-form-preview__item" th:if="${tran.type == 2}">装配件</a>
                <a class="weui-form-preview__item" th:if="${tran.type == 3}">返修票</a>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">工艺路线</label>
                <b class="weui-form-preview__item" th:text="${tran.route} +'    '+ ${tran.orderNo}"></b>
            </div>
            <div th:if="${tran.transMode == 2}" class="weui-form-preview__item">
                <label class="weui-form-preview__label">工艺工序</label>
                <b class="weui-form-preview__item" th:text="${tran.process} +'    '+ ${tran.handNo}"></b>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">数量</label>
                <b class="weui-form-preview__item" th:text="${tran.num}"></b>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">申请人姓名</label>
                <b class="weui-form-preview__item" th:text="${tran.applyName}"></b>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">申请人部门</label>
                <b class="weui-form-preview__item" th:text="${tran.applyDept}"></b>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">申请时间</label>
                <b class="weui-form-preview__item" th:text="${#dates.format(tran.applyTime, 'yyyy-MM-dd HH:mm')}"></b>
            </div>
        </div>
        <div class="weui-form-preview__ft">
            <button type="button" class="weui-form-preview__btn weui-form-preview__btn_primary"
                    th:onclick="|success(${tran.id})|">质检合格
            </button>
            <button type="button" class="weui-form-preview__btn weui-form-preview__btn_default"
                    th:onclick="|reject(${tran.id})|">质检驳回
            </button>
        </div>
    </div>

</div>
<div class="weui-tabbar">
    <a th:href="@{/index}" class="weui-tabbar__item weui-bar__item--on">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/me.png}" alt="">
        </div>
        <p class="weui-tabbar__label">我的信息</p>
    </a>

    <!--生产历史-->
    <a th:if="${#strings.contains(session.user.roles,'【申请质检】')}" th:href="@{/hisApply/null/null}" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_apply.png}" alt="">
        </div>
        <p class="weui-tabbar__label">历史申请</p>
    </a>
    <a th:if="${#strings.contains(session.user.roles,'【转序接收】')}" th:href="@{/hisRec/null/null}" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_rec.png}" alt="">
        </div>
        <p class="weui-tabbar__label">历史接收</p>
    </a>
    <a th:if="${#strings.contains(session.user.roles,'【转序质检】')}" th:href="@{/hisCheck/null/null}" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_check.png}" alt="">
        </div>
        <p class="weui-tabbar__label">历史质检</p>
    </a>
    <a th:if="${#strings.contains(session.user.roles,'【入库质检】')}" onclick="tips()" href="javascript:void(0)" class="weui-tabbar__item">
        <div class="weui-tabbar__icon">
            <img th:src="@{/img/his_check.png}" alt="">
        </div>
        <p class="weui-tabbar__label">入库历史质检</p>
    </a>
</div>
<div id="pop-reject" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar">
            <div class="toolbar-inner">
                <a href="javascript:void(0);" class="picker-button close-popup">关闭</a>
                <h1 class="title">驳回</h1>
            </div>
        </div>
        <div class="modal-content">
            <form id="reject-form">
                <input id="reject-id" type="hidden" name="transId">
                <div class="weui-cells weui-cells_form">
<!--                    <div class="weui-cell weui-cell_switch">-->
<!--                        <div class="weui-cell__bd">作废</div>-->
<!--                        <div class="weui-cell__ft">-->
<!--                            <input class="weui-switch" type="checkbox" name="status" value="1">-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="weui-textarea" name="reason" rows="3" placeholder="请输入驳回原因"></textarea>
                        </div>
                    </div>
                </div>
            </form>
            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_primary" href="javascript:" id="btn-reject">确定</a>
            </div>
        </div>
    </div>
</div>

<div id="pop-success" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar">
            <div class="toolbar-inner">
                <a href="javascript:void(0);" class="picker-button close-popup">关闭</a>
                <h1 class="title">合格</h1>
            </div>
        </div>
        <div class="modal-content">
            <form id="success-form">
                <input id="success-id" type="hidden" name="transId">
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell weui-cell_switch">
                        <div class="weui-cell__bd">让步接收</div>
                        <div class="weui-cell__ft">
                            <input class="weui-switch" type="checkbox" name="yield" value="1">
                        </div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="weui-textarea" name="reason" rows="3" placeholder="请输入质检意见"></textarea>
                        </div>
                    </div>
                </div>
            </form>
            <div class="weui-btn-area">
                <a class="weui-btn weui-btn_primary" href="javascript:" id="btn-success">确定</a>
            </div>
        </div>
    </div>
</div>
<a id="jumpPage" style="display: none" th:href="@{/editCheckInfo/{result}/{id}(result='SUCCESS',id=${tran.id})}"/>
<div th:include="include :: appFooter"></div>
<script th:inline="javascript">
    let tranId = [[${tran.id}]]
    function reject(id) {
        $("#pop-reject").popup();
        $("#reject-id").val(id);
    }
    function success(id) {
        $("#pop-success").popup();
        $("#success-id").val(id);
    }
    $(function () {
        $("#btn-success").click(function (e) {
            $("#btn-success").hide();
            let reason = $("#success-form [name='reason']").val();
            let yield =  $("#success-form [name='yield']");
            if (yield.prop("checked") && (reason === undefined || reason === null || reason.replace(/[\r\n]/g, "") === '')) {
                $.box.toptip_w('请输入质检意见！');
                return;
            }
            $.operate.submit({
                url: ctx + 'success',
                data: new FormData($("#success-form")[0]),
                fun: function () {
                    // location.href = ctx + "index";
                    // location.href = ctx + "editCheckInfo/success/"+tranId;
                    document.getElementById("jumpPage").click();//模拟点击
                }
            });
        })

        $("#btn-reject").click(function (e) {
            $("#btn-reject").hide();
            let reason = $("#reject-form [name='reason']").val();
            if (reason === undefined || reason === null || reason.replace(/[\r\n]/g, "") === '') {
                $.box.toptip_w('请输入驳回原因！');
                $("#btn-reject").show();
                return;
            }
            $.operate.submit({
                url: ctx + 'reject',
                data: new FormData($("#reject-form")[0]),
                fun: function () {
                    // location.href = ctx + "index";
                    // location.href = ctx + "uploadFile";
                    document.getElementById("jumpPage").click();//模拟点击
                }
            });
        })
    })
    // function jumpPage(){
    //     location.href = ctx + "uploadFile";
    // }
</script>
</body>
</html>